<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <canvas id="canvas" style="border: 1px solid #aaa; display: block; margin: 50px auto;">
        当前浏览器不支持Canvas，请更换浏览器
    </canvas>
    <script>
        window.onload = function () {
            var canvas = document.getElementById("canvas");

            canvas.width = 800;
            canvas.height = 800;

            var context = canvas.getContext("2d");

            fillMoon(context, 2, 400, 400, 300, 0);
        }

        function fillMoon(cxt, d, x, y, R, rot, /*optional*/fillColor) {
            cxt.save();
            cxt.translate(x, y);
            cxt.rotate(rot * Math.PI / 180);
            cxt.scale(R, R);
            pathMoon(cxt, d);
            cxt.fillStyle = fillColor || '#fb5';
            cxt.fill();
            cxt.restore();
        }

        function pathMoon(cxt, d) {
            cxt.beginPath();
            cxt.arc(0, 0, 1, 0.5*Math.PI, 1.5*Math.PI, true);
            cxt.moveTo(0, -1);
            cxt.quadraticCurveTo(1.2, 0, 0, 1);
            cxt.closePath();
        }
    </script>
</body>
</html>